package com.example.app;

import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.util.*;
import java.time.Instant;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Date time1 = new Date();
        long time = new Date().getTime();
        System.out.println(time);
        System.out.println(time);
        List<Dogs> a = new ArrayList<>();
        Date time2 = new Date(time + 1000);
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(time1.equals(time2));
        Instant it = Instant.now();
        System.out.println(it.getNano());
        System.out.println(it.getEpochSecond());
        System.out.println();
        String number = "02746880132";
        System.out.println(number.matches("\\w{5,9}@\\w{2,9}(\\.\\w{2,10}){1,2}"));
        Dogs dog = new Dogs();
        dog.init("你好", 20);
        Dogs dog2 = new Dogs();
        dog2.init("你好", 21);
        a.add(dog);
        a.add(dog2);
//        Arrays.sort(a, new Comparator<Dogs>(){
//            public int compare(Dogs o1, Dogs o2){
//                return Integer.compare(o1.age, o2.age);
//            }
//        });
//        System.out.println(a[0]);
        List<Dogs> temp = a.stream().filter(b -> b.age > 20).collect(Collectors.toList());
        System.out.println(temp);
    }

    abstract static class Animal{
        private String name;
        public void init(String name){
            this.name = name;
        }
        public void introduce(){
            System.out.println("name:" + this.name);
        }
    }
    public interface A_Flyable{
        void fly();
    }
    public interface B_driveable{
        void drive();
    }
    static class Dogs extends Animal implements A_Flyable, B_driveable, Comparable<Dogs>{
        private int age;
        public Dogs(){
            super.init("e");
            this.age = 10;
        }
        public void init(String name, int age){
            super.init(name);
            this.age = age;
        }
        @Override public void fly(){

        }
        public String toString(){
            return("age" + age);
        }
        @Override
        public void drive() {

        }

        @Override public void introduce(){
            super.introduce();
            System.out.println("age:"+this.age);
        }
        @Override
        public int compareTo(Dogs o){
            return this.age -o.age;
        }

    }
}

